package cn.csc.module.product.controller.admin.spu.vo;

import cn.csc.module.product.validated.CheckPriceInterval;
import cn.csc.module.product.validated.Verify1;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;

/**
 * @author: 云隐
 * @Date: 2024/01/09
 **/
@ApiModel("管理后台 - spu信息规格属性 Request VO")
@Data
@ToString(callSuper = true)
@CheckPriceInterval(start = "priceFee", end = "shopPriceFee", verify = "hasShop", message = "售价为空或企业购售价不能高于市场售价")
public class SkuAttrCreateReqVO implements Serializable {

    @ApiModelProperty(value = "skuId")
    private BigInteger skuId;
    @ApiModelProperty(value = "商品编码")
    public String partyCode;
    @ApiModelProperty(value = "是否企业购 0：否 1:是")
    public Integer hasShop;
    @NotNull(message = "规格不能为空")
    @Length(min = 2, max = 10, message = "规格名称字符范围2-10个字")
    @ApiModelProperty(value = "规格名称")
    public String attrName;
    @ApiModelProperty(value = "价格")
    @Digits(integer = 9, fraction = 2, message = "售价格式不正确,只能保留两位小数")
    @DecimalMin(value = "0.01", message = "售价必须大于0")
    @DecimalMax(value = "50000", message = "售价最大50000")
    @NotNull(message = "售价不能为空")
    private BigDecimal priceFee;
    @ApiModelProperty(value = "企业购价格")
    @Digits(integer = 9, fraction = 2, message = "售价格式不正确,只能保留两位小数")
    @DecimalMin(value = "0.01", message = "售价必须大于0", groups = Verify1.class)
    @DecimalMax(value = "50000", message = "售价最大50000", groups = Verify1.class)
    @NotNull(message = "企业购售价不能为空", groups = Verify1.class)
    private BigDecimal shopPriceFee;

}
